#ifndef __BSP_H__
#define __BSP_H__

#include "main.h"
#include "stdio.h"

#define RCC_HSE_Enable      0       // 使能HSE
#define BSP_TICKS_PER_SEC   1000U

#define BSP_Debug           1
#define BSP_ASSERT_Enable   0

#define Bsp_hw_interrupt_disable()      __disable_irq()
#define Bsp_hw_interrupt_enable()       __enable_irq()

#define Bsp_SysTick_Start()             SET_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk)
#define Bsp_SysTick_Stop()              CLEAR_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk)

void BSP_init(void);
void BSP_Startup(void);
void BSP_TickDelay(uint32_t Delay);
void BSP_usDelay(uint32_t usDelay);

// 测试函数运行时间
void BSP_DWT_Rst(void);
uint32_t BSP_DWT_Get_usTime(void);

#if BSP_Debug
    #define DEBUG_RST_PORT      GPIOA
    #define DEBUG_RST_PIN       LL_GPIO_PIN_0
#endif

#if BSP_ASSERT_Enable
    void BSP_onAssert(char *file, uint32_t line);
    #define BSP_Assert(n)       (n == 0) ? BSP_onAssert((char *)__FILE__, __LINE__) : (void)0;
#else
    #define BSP_Assert(n)
#endif

#endif
